package ch01;

public class MoneyTest4 {
    public static void main(String[] args) {
        int money=2;
        money=money-3;
        double r1= Math.random();
        double r2= Math.random();
        double r3= Math.random();

        // 求和
        double sum=r1+r2+r3;

        // 按比例分配
        int i1= (int)(r1/sum*money);
        int i2= (int)(r2/sum*money);
        int i3= money-i1-i2;

        // 1分钱
        i1=i1+1;
        i2=i2+1;
        i3=i3+1;

        // 保留两位小数
        System.out.println(i1/100.0);
        System.out.println(i2/100.0);
        System.out.println(i3/100.0);

    }
}
